<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css"
			href="http://localhost:8075/webroot/decision/view/report?op=emb&resource=finereport.css&cssVersion=1690269339236" />
		<style type="text/css">
			.top {
				height: 50px;
				padding: 10px;
				text-align: center;
				background-color: #F7F8FA;
			}
		</style>
	</head>
	<body>
		<div class="top">

			<div class="fr-btn ui-state-enabled" onclick="sendGenerate()" widgetname="BUTTON0"
				style="width: 116px; height: 21px; left: 374px; top: 17px; position: absolute;">
				<div id="fr-btn-BUTTON0" class="fr-btn-up  fr-btn-noicon fr-widget-background"
					style="height: 21px; width: 116px; display: table-cell;">
					<div class="fr-btn-small fr-btn-icon-small-left"><em unselectable="on"><button unselectable="none"
								type="button" data-role="none" class="fr-btn-text fr-widget-font"
								style="max-width: 110px;">生成采购申请</button></em></div>
				</div>
			</div>

		</div>
		<div id="filelist"></div>

	</body>
</html>
<script
	src="http://localhost:8075/webroot/decision/view/report?op=emb&resource=finereport.main.js&inter=zh_CN&__fr_locale__=&jsVersion=1690269339236"
	type="text/javascript" charset="utf-8"></script>
<script src="http://localhost:8075/webroot/decision/file?path=/com/fr/web/ui/fineui.min.js&type=plain&parser=plain"
	type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
	function sendGenerate() {
		FR.showLoadingDialog()
		var xhr = new XMLHttpRequest();
		xhr.addEventListener("readystatechange", function() {
			if (this.readyState === 4) {
				FR.hideLoadingDialog()
				let res = JSON.parse(this.responseText);
				if (res.code == 200) {
					FR.Msg.alert("提示", "已生成，共计耗时" + res.message + "秒");
				} else {
					FR.Msg.alert("错误", res.message);
				}
			} else {
			}
		});
		xhr.open("GET", "http://localhost:8080/auto-report-1/pack/poRequest/generate");
		xhr.send();
	}

	function getFileList() {
		var xhr = new XMLHttpRequest();
		let dom = "";
		xhr.addEventListener("readystatechange", function() {
			if (this.readyState === 4) {
				console.log(this.responseText);
				let json = JSON.parse(this.responseText)
				if (json.code == 200) {
					let list = json.data;
					for (var i = 0; i < list.length; i++) {
						let file = list[i]

						dom += `<div style='margin:5px;border:1px solid #ccc;border-radius:5px;min-width:300px;float:left;padding:5px;'>
						<img src="excel.png" >
						<strong>${file.name}</strong>
						<div><span style="font-size: 12px;">${file.size}</span></div>
						<div>
							<span style="font-size: 12px;">${file.createDatetime}</span>
							<a style="font-size: 12px;" href="http://localhost:8080/auto-report-1/pack/file/download?fileName=${file.name}">下载</a>
						</div>
					</div>`;
					}
					document.getElementById("filelist").innerHTML = dom;
				}
			}
		});
		xhr.open("GET", "http://localhost:8080/auto-report-1/cell/poRequest/generated/list");
		xhr.send();
	}
	setTimeout(function() {
		getFileList();
	}, 1000)
</script>
